import { scrollMixin } from "../../../utils/mixin";
// import lineEcharts from "./components/lineEcharts";
// import indexGroupItem from "./components/index_group_item";
// import qrcode from "./components/qrcode";
// import filterPopup from "./components/filter-popup";
// import inviterMemberItem from "./components/inviter-member-item";
// import sharePoster from "./components/share_poster";

import { Toast } from "vant";
export default {
    mixins: [scrollMixin], //加载更多
    //   components: { lineEcharts, indexGroupItem, qrcode, filterPopup, inviterMemberItem, sharePoster },
    data() {
        return {
            listData: [],
            page: 1, //分页数，当前页数
            isLoadMore: true, //判断是否要加载更多的标志
            total_page: 0, //总页数
            hongbao_money:''
        };
    },
    activated() {
        window.scrollTo(0, 0);
        // this.getEmployee();
        this.getListData();
    },

    methods: {
        viewRecord(){
            this.$router.push(this.fun.getUrl("HongbaoRecord"))
        },
        initData() {
            this.page = 1;
            this.isLoadMore = true;
            this.total_page = 0;
        },
        // 格式化时间戳
        timestampToDateTime(timestamp) {
            var date = new Date(timestamp * 1000); // JavaScript中的时间戳单位是毫秒，需要乘以1000才能正确显示

            var year = date.getFullYear();
            var month = ("0" + (date.getMonth()+1)).slice(-2); // 获取月份并补零
            var day = ("0" + date.getDate()).slice(-2); // 获取天数并补零
            var hours = ("0" + date.getHours()).slice(-2); // 获取小时并补零
            var minutes = ("0" + date.getMinutes()).slice(-2); // 获取分钟并补零
            var seconds = ("0" + date.getSeconds()).slice(-2); // 获取秒数并补零

            return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
        },
        //获取更多数据
        getMoreData() {
            console.log('hongbao', this.isLoadMore)
            if (!this.isLoadMore) return;
            this.isLoadMore = false; // 防止多次请求分页数据
            if (this.page >= this.total_page) {
                return;
            } else {
                this.page += 1;
                let json = {
                    uid: localStorage.getItem("uid"),
                    page: this.page
                };
                let _url = "Feilong.user_list";
                $http.post(_url, json).then(response => {
                    if (response.result === 1) {
                        console.log(response.data, 'data')
                        var nextPageData = response.data.data
                        //   var nextPageData = response.data.record_list.data;
                        //   this.money_arr = Object.assign(this.money_arr, response.data.point_arr);
                        // for (const key in nextPageData) {
                        //     console.log(key,'llll')
                        //     if (this.listData.data[key]) {
                        //       this.$set(this.listData.data, key, [...this.listData.data[key], ...nextPageData[key]]);
                        //     } else {
                        //       this.$set(this.listData.data, key, nextPageData[key]);
                        //     }
                        //     // if (this.record_list.data[key]) {
                        //     //   this.$set(this.record_list.data, key, [...this.record_list.data[key], ...nextPageData[key]]);
                        //     // } else {
                        //     //   this.$set(this.record_list.data, key, nextPageData[key]);
                        //     // }
                        // }
                        this.listData = [...this.listData, ...nextPageData]
                        this.isLoadMore = true;
                        console.log(this.listData, 'ffdfdd')
                        //   console.log(this.record_list.data);
                    } else {
                        this.page = this.page - 1;
                        this.isLoadMore = false;
                    }
                });
            }
        },

        // setTabIndex(index) {
        //   if (index == this.tabIndex) return;
        //   if (this.owner == null) this.getOwner();
        //   this.tabIndex = index;
        //   this.childTabIndex = this.tabIndex == 0 ? 0 : 3;
        //   this.getListData();
        // },
        // setChildTabIndex(index) {
        //   if (index == this.childTabIndex) return;
        //   this.childTabIndex = index;
        //   this.getListData();
        // },
        getListData() {
            console.log('1111')
            Toast.loading({
                message: "",
                forbidClick: true
            });
            this.initData();
            let _url = "Feilong.user_alllist";

            $http.get(_url, {}).then(res => {
                Toast.clear();
                if (res.result !== 1) {
                    Toast(res.msg);
                    return;
                }

                this.listData = res.data.list;
                this.hongbao_money = res.data.money
                console.log( res.data.money, 'this.listData123')
                // this.isLoadMore = true;
                // this.total_page = res.data.last_page;
                // if (!this.total_page) {
                //     this.total_page = 0;
                // }

                // console.log(res);
            });
        },

    }
};
